package tau.adx.common.devices.generators;

import java.util.Collection;
import java.util.LinkedList;
import java.util.Random;

import tau.adx.common.devices.Device;
import tau.adx.common.generators.GenericGenerator;

/**
 * A naive implementation of the {@link GenericGenerator} interface. Randomizes
 * {@link Device devices}.
 * 
 * @author greenwald
 * 
 */
public class SimpleDeviceGenerator implements GenericGenerator<Device> {

	/**
	 * @see tau.adx.common.generators.GenericGenerator#generate(int)
	 */
	@Override
	public Collection<Device> generate(int amount) {
		Collection<Device> devices = new LinkedList<>();
		for (int i = 0; i < amount; i++) {
			devices.add(randomDevice());
		}
		return devices;
	}

	/**
	 * @return A random {@link Device}.
	 */
	public static Device randomDevice() {
		Random random = new Random();
		return Device.values()[(random.nextInt(Device.values().length))];
	}
}
